﻿using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CreaMotion.UserControls
{
	/// <summary>
	/// Interaction logic for Table.xaml
	/// </summary>
	public partial class Table : UserControl
	{
        public ObservableCollection<UserControls.FieldItem> FieldsSource = new ObservableCollection<UserControls.FieldItem>();

    	public Table()
		{
			this.InitializeComponent();

            ListFields.ItemsSource = FieldsSource;

            #region Events

            #endregion
        }

        #region Source

        private Interfaces.Table source;
        public Interfaces.Table Source
        {
            get
            {
                return source;
            }
            set 
            {
                source = value;
                if (value == null) return;

                labTableName.Text = value.TableName;
                foreach (Interfaces.Field field in value.Fields)
                {
                    FieldsSource.Add(new UserControls.FieldItem() { Source = field });
                }
            }
        }

        #endregion
    }
}